<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<title>Processing.js test of loadBytes() (0)</title>
		<script type="text/javascript" src="../../../processing.js"></script>
		<style type="text/css">
			html{
				background: #EEEEEE;
			}
			#title{
				font-size:xx-large;
				font-weight:bold;
				padding:0.5em;
				background: #385C85;
				color: #FFFFFF;
			}
			p{
				line-height: 1.3em;
			}
			p a{
				color: #385C85;
			}
			#code{
				border-style: dotted;
				border: 1px solid #333333;
				background-color: #FFFFFF;
				padding: 0.5em;
			}
		</style>
	</head>
	<body>
		<div id="title">Processing.js test of loadBytes() (0)</div>
		<h2></h2>
		<script id="script" type="application/processing">
boolean errors=false;

int xcoord=5;
int xoff=10;
int ycoord=35;
int yinc=15;

void setup() {
	size(300,200);
	background(50);
	noLoop();
} 

void draw() {
        
        byte[] expVal=new byte[3];
        expVal[0]=33;
        expVal[1]=65;
        expVal[2]=97;
        outputIntArr(4,"loadBytes(\"test\")",loadBytes("loadBytesTestFile"),expVal);

	xcoord=300;
	ycoord=35;

	String errMsg="";
	if (errors) {
		fill(255,0,0);
		errMsg="RED tests FAILED.";
	} else {
		fill(0,255,0);
		errMsg="All tests passed.";
	}
	text(errMsg,5,20);
}

void outputIntArr(int ind,String txt,byte[] results,byte[] expected) {
	fill(255,255,255);
	text("["+ind+"] "+txt,xcoord,ycoord+=yinc);

        String resOut="";
        fill(0,255,0);
        for (int i=0;i<results.length;i++) {
           
           if (i>=expected.length || !(results[i]==expected[i])) {
               fill(255,0,0);
               errors=true;
           }
           resOut=resOut+results[i]+", ";
        }

	text(resOut,xcoord+xoff,ycoord+=yinc);
	ycoord+=yinc;
}
		</script>
		<canvas id="display"></canvas>
		<p><strong>Test written by <a href="http://zenit.senecac.on.ca/wiki/index.php/User:Mlam19">Matthew Lam</a></strong></p>
		<pre id="code"></pre>
		<script type="text/javascript">
			var canvas = document.getElementById('display');
			var script = document.getElementById('script').innerHTML;
			document.getElementById('code').innerHTML=script;
			var source = script.replace(/[^\.]size\(\)\;/,'size('+ canvas.width +','+ canvas.height +');');
			Processing(canvas,source);
		</script>
	</body>
</html>

